#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=2e5+1000;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
int a[5]={0,1,2,3,4};
int main(void){
   	cin.tie(0);std::ios::sync_with_stdio(false);
   	LL t;cin>>t;
   	while(t--)
    {
        LL n2,n3,n4;
        cin>>n2>>n3>>n4;
        LL res=0;
        do{
            LL num2=n2;LL num3=n3;LL num4=n4;
            LL ans=0;
            for(int i=0;i<5;i++)
            {
                if(a[i]==0)
                {
                    LL cnt=min(num4,num3/2);
                    ans+=cnt;
                    num4-=cnt; num3-=2*cnt;
                }
                if(a[i]==1)
                {
                    LL cnt=min(num3/2,num2/2);
                    ans+=cnt;
                    num3-=cnt*2; num2-=cnt*2;
                }
                if(a[i]==2)
                {
                    LL cnt=num2/5;
                    ans+=cnt;
                    num2-=cnt*5;
                }
                if(a[i]==3)
                {
                    LL cnt=min(num4,num2/3);
                    ans+=cnt;
                    num4-=cnt;  num2-=cnt*3;
                }
                if(a[i]==4)
                {
                    LL cnt=min(num4/2,num2);
                    ans+=cnt;
                    num4-=cnt*2; num2-=cnt;
                }
            }
            res=max(res,ans);
        }while(next_permutation(a,a+5));
        cout<<res<<endl;
    }
   	return 0;
}
